package com.amoos.ssmPractice1.controller;

import com.amoos.ssmPractice1.service.ItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import pojo.Item;
//k可以了！！！！！
@Controller
@RequestMapping("/item")
public class ItemController {
    @Autowired
    private ItemService itemService;

    @RequestMapping("/showItem/{id}")/*把网页的url带的参数传进来*/
    public String findById(@PathVariable("id") int id, Model model){
        Item item= itemService.findById(id);
        model.addAttribute("item",item);
        return "item";//跳转到某个页面，在SpringMVC配置后，会跳转到item.jsp

    }
}
